package zzzEclipseLink;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import po.Customers;

public class TestPsistence {
	public static void main(String[] args) {
//		EntityManagerFactory factory= Persistence.createEntityManagerFactory("john");
		ApplicationContext context=new ClassPathXmlApplicationContext("applicationContext.xml");
		EntityManagerFactory factory=(EntityManagerFactory)context.getBean("entityManagerFactory");
		EntityManager em=factory.createEntityManager();
		Customers c=new Customers();
		c.setCname("ttt1");
		c.setSex(true);
		EntityTransaction tx=em.getTransaction();
		tx.begin();
		em.persist(c);
		tx.commit();
		em.close();
	}
}
